Socket
Socket
Sign inDemoInstall

rollup-plugin-hypothetical

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rollup-plugin-hypothetical

gives Rollup an imaginary file system, e.g. for testing other plugins


Version published
Weekly downloads
16K
decreased by-11.35%
Maintainers
1
Weekly downloads
 
Created
Source

rollup-plugin-hypothetical npm Dependency Status Build Status

This allows Rollup modules to import hypothetical files passed in as options to the plugin.

Installation

npm install --save-dev rollup-plugin-hypothetical

Usage

// rollup.config.js
import hypothetical from 'rollup-plugin-hypothetical';

export default {
  entry: './dir/a.js',
  plugins: [hypothetical({
    files: {
      './dir/a.js': `
        import foo from './b.js';
        foo();
      `,
      './dir/b.js': `
        export default function foo() {
          console.log("Hello, world!");
        }
      `
    }
  })]
};

Sourcemaps

To attach a sourcemap to a hypothetical file, simply pass in a { code, map } object instead of a string. The sourcemap can have its own sources, sourcesContent, etc.

Options

options.files

An object whose keys are paths, either relative to the current working directory or absolute, and whose values are the code within the hypothetical files at those paths.

options.allowRealFiles

Set this to true to allow mixing of hypothetical and actual files. "Actual" files can be files accessed by Rollup or produced by plugins further down the chain.

options.allowExternalModules

Set this to false to forbid importing of external modules.

options.leaveIdsAlone

When this is set to true, the IDs in import statements won't be treated as paths and will instead be looked up directly in the files object. There will be no relative importing, path normalization, or restrictions on the contents of IDs.

options.impliedExtensions

Set this to an array of file extensions to try appending to imports if an exact match isn't found. Defaults to ['.js']. If this is set to false or an empty array, file extensions in imports will be treated as mandatory.

options.cwd

When this is set to a directory name, relative file paths will be resolved relative to that directory rather than process.cwd(). When it's set to false, they will be resolved relative to an imaginary directory that cannot be expressed as an absolute path.

License

MIT

Keywords

FAQs

Package last updated on 07 Aug 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc